<?php

/**
 * This file is part of the Codizer package.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @copyright   Copyright (c) 2010 Advisa (http://www.advisa.fr)
 * @author      Codizer Core Team <team@codizer.org>
 * @package     Codizer
 */

function smarty_function_backend_image($params, &$smarty)
{
    if(!isset($params['file']) || is_null($params['file']) || $params['file'] == "")
    {
        return "";
    }

	$conf = f_loader_Config::getInstance()->getParameters("default");
	
	$path = URL_RELATIVE."/themes/".$conf['backTheme']."/backend/medias/pictures/".$params['file'];
		
	if(isset($params['getOnlyPath']) && $params['getOnlyPath'] == 'true')
	{
		return $path;
	}
    else
    {
        $params['alt'] = isset($params['alt']) ? $params['alt'] : "";
        $params['title'] = isset($params['title']) ? $params['title'] : "";
        unset($params['file']);

        $datas = "";

        foreach($params as $key => $param)
        {
            $datas .= " ".$key."='".$param."'";
        }
    }
	    
	return '<img src="'.$path.'"'.$datas.' />';
}
